package com.jiazhong.spring.ai.elasticsearch.controller;

import com.jiazhong.spring.ai.elasticsearch.service.OllamaService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
@CrossOrigin
@Slf4j
@RestController
@RequestMapping("/ollama/ai")
public class OllamaController {
    @Resource
    private OllamaService ollamaService;

   // @RequestMapping(value = "/stream", produces = "text/event-stream;charset=utf-8")
    @RequestMapping("/stream")
    //@RequestMapping(value = "/stream", produces = "text/stream;charset=utf-8")
    public Flux<String> stream(@RequestParam("question") String question) {
        log.info("question:{}", question);
        return ollamaService.stream(question);
    }
}
